(function() {
    angular.module('app').factory('customPaginationService', customPaginationService);

    customPaginationService.$inject = [];

    function customPaginationService() {

        var realPagination = {
            begin: 0,
            count: 10,
            newPageNumber: 1,
            pages: 10000,
            currentPage: 0,
            onPageChange: function() {

                vm.pagination.begin = (this.currentPage - 1) * vm.pagination.count;
                _init();
            }
        };

        return {
            // set: _set,
            get: _get,
            pageChange: _pageChange,
            pageChangeCount: _pageChangeCount,
            reset: _reset
        };

        function _set(obj) {

            pagination = angular.extend({}, pagination, obj);

        }

        function _get() {

            return angular.copy(realPagination);
        }


        function _pageChange(pagination,pageNumber) {

        	pagination.newPageNumber = pageNumber;
            pagination.begin = (pagination.newPageNumber - 1) * pagination.count;

        }

        function _pageChangeCount(pageNumber) {

        	pagination.newPageNumber = pageNumber;
            pagination.begin = (pagination.newPageNumber - 1) * pagination.count;

        }

        function _reset(obj) {

            var pagination = angular.copy(realPagination);

            pagination = angular.extend({}, pagination, obj);

            return pagination;

        }




    }
})();
